import random
print("""
*******************************************
     这是一个悲伤的随机四则运算小孩哥用程序
     作者：独之 陈    日期：2025/3/26
*******************************************
     """)
def generate_question():
    num1 = random.randint(1, 100)
    num2 = random.randint(1, 100)
    operators = ['+', '-', '*', '/']
    operator = random.choice(operators)
    question = f"{num1} {operator} {num2}"
    if operator == '+':
        answer = num1 + num2
    elif operator == '-':
        answer = num1 - num2
    elif operator == '*':
        answer = num1 * num2
    else:
        answer = round(num1 / num2, 2)
    return question, answer

num_questions = 5
correct_count = 0
for i in range(num_questions):
    question, answer = generate_question()
    user_answer = input(f"问题 {i + 1}: {question} = ")
    try:
        user_answer = float(user_answer)
        if user_answer == answer:
            print("回答正确！")
            correct_count += 1
        else:
            print(f"回答错误，正确答案是 {answer}。")
    except ValueError:
        print("输入无效，请输入一个数字。")

print(f"你一共回答了 {num_questions} 个问题，答对了 {correct_count} 个。")
